/**
 * Copyright (c) 2006 RiseSoft Co.,Ltd  
 * $Header$
 */
package cn.newtest.bi.collection.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

/**
 *
 *
 * @author <a href="mailto: chenjian@risesoft.net">陈健</a>
 * @version $Revision$
 * 
 */
@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Table(name="Rpt_ReportInstance")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class ReportInstance implements Serializable {
	private static final long serialVersionUID = 5135390694155881520L;
	
	public static final int STATUS_NO = 0;
	public static final int STATUS_HASNORMALERROR = 2;
	public static final int STATUS_YES = 100;
	
	@Id
	@Column(name="ReportInstance_Guid",length=38)
	@GenericGenerator(name="ReportInstance-assigned",strategy="assigned")
	private String guid;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="Service_guid",nullable=false)
	private Service service;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="Application_guid",nullable=false)
	private Application application;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="Speciality_GUID",nullable=true)
	private Speciality speciality;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="Template_guid",nullable=false)
	private Template template;

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="ReportPeriod_Guid",nullable=false)
	private ReportPeriod reportPeriod;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="ReportPeriod_Type_GUID",nullable=false)
	private ReportPeriodType reportPeriodType;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="ReportPeriod_Template_guid",nullable=false)
	private ReportWindowPeriod reportWindowPeriod;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="so_Guid",nullable=false)
	private Catalog so;

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="soType_guid",nullable=false)
	private SoType soType;
	
	@Column(name="so_instance_guid",length=38,nullable=false)
	private String soInstanceGuid;
	
	@Column(name="so_instance_name",length=200)
	private String soInstanceName;
	
	@Column(name="so_instance_code",length=20)
	private String soInstanceCode;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date firstUploadDate;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastModifiedDate;
	
	@Basic
	private Integer status;
	
	@Basic
	private Integer lockStatus;
	
	@Basic
	private Double tabIndex;
	
	@Transient
	public String getItem_guid() {
		return soInstanceGuid;
	}
	
	@Transient
	public String getItem_code() {
		return soInstanceCode;
	}
	
	@Transient
	public String getItem_name() {
		return soInstanceName;
	}
	
	@Transient
	public String getSoTypeName() {
		if(getSoType()==null){
			return "未设置";
		}else{
			return getSoType().getName();
		}		
	}
	
	@Transient
	public String getTemplateGuid() {
		return template.getGuid();
	}
	
	@Transient
	public String getReportPeriodGuid() {
		return reportPeriod.getGuid();
	}
	
	public ReportWindowPeriod getReportWindowPeriod() {
		return reportWindowPeriod;
	}

	public void setReportWindowPeriod(ReportWindowPeriod reportWindowPeriod) {
		this.reportWindowPeriod = reportWindowPeriod;
	}
	
	public Date getFirstUploadDate() {
		return firstUploadDate;
	}

	public void setFirstUploadDate(Date firstUploadDate) {
		this.firstUploadDate = firstUploadDate;
	}

	public Date getLastModifiedDate() {
		return lastModifiedDate;
	}

	public void setLastModifiedDate(Date lastModifiedDate) {
		this.lastModifiedDate = lastModifiedDate;
	}

	public String getSoInstanceName() {
		return soInstanceName;
	}

	public void setSoInstanceName(String soInstanceName) {
		this.soInstanceName = soInstanceName;
	}

	public String getSoInstanceCode() {
		return soInstanceCode;
	}

	public void setSoInstanceCode(String soInstanceCode) {
		this.soInstanceCode = soInstanceCode;
	}

	public Catalog getSo() {
		return so;
	}

	public void setSo(Catalog so) {
		this.so = so;
	}

	public String getSoInstanceGuid() {
		return soInstanceGuid;
	}

	public void setSoInstanceGuid(String soInstanceGuid) {
		this.soInstanceGuid = soInstanceGuid;
	}

	public Integer getLockStatus() {
		return lockStatus;
	}

	public void setLockStatus(Integer lockStatus) {
		this.lockStatus = lockStatus;
	}

	public String getGuid() {
		return guid;
	}

	public void setGuid(String guid) {
		this.guid = guid;
	}

	public Template getTemplate() {
		return template;
	}

	public void setTemplate(Template template) {
		this.template = template;
	}
	
	public ReportPeriod getReportPeriod() {
		return reportPeriod;
	}

	public void setReportPeriod(ReportPeriod reportPeriod) {
		this.reportPeriod = reportPeriod;
	}
	
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Double getTabIndex() {
		return tabIndex;
	}

	public void setTabIndex(Double tabIndex) {
		this.tabIndex = tabIndex;
	}

	public Service getService() {
		return service;
	}

	public void setService(Service service) {
		this.service = service;
	}

	public Application getApplication() {
		return application;
	}

	public void setApplication(Application application) {
		this.application = application;
	}

	public Speciality getSpeciality() {
		return speciality;
	}

	public void setSpeciality(Speciality speciality) {
		this.speciality = speciality;
	}

	public ReportPeriodType getReportPeriodType() {
		return reportPeriodType;
	}

	public void setReportPeriodType(ReportPeriodType reportPeriodType) {
		this.reportPeriodType = reportPeriodType;
	}

	public SoType getSoType() {
		return soType;
	}

	public void setSoType(SoType soType) {
		this.soType = soType;
	}

}
